{include file="common/mainHead"/}
<div class="admin-main fadeInUp animated" ng-app="hd" ng-controller="ctrl">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>添加分类</legend>
    </fieldset>
    <form class="layui-form layui-form-pane">
    	
    	<div class="layui-form-item">
            <label class="layui-form-label">所属分类</label>
            <div class="layui-input-4">
            	 <select name="pid" lay-verify="required" lay-filter="pid" >
                    <option value="0">默认顶级</option>
                    {volist name="list" id="vo"}
                        <option value="{$vo.id}">{$vo.lefthtml}{$vo.title}</option>
                    {/volist}
                </select>
            	
            	
              </div>
        </div>
        
        <div class="layui-form-item">
            <label class="layui-form-label">添加分类</label>
            <div class="layui-input-4">
                <input type="text" name="title" ng-model="field.title" lay-verify="required" placeholder="标题" class="layui-input">
            </div>
        </div>
       <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-block">
                <textarea placeholder="内容" name="desc" rows="15" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
                <a href="{:url('index')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
            </div>
        </div>
    </form>
</div>
{include file="common/mainFoot"/}
<script src="__STATIC__/js/angular.min.js"></script>
<script>
       layui.use(['form', 'layer'], function () {
        var form = layui.form(), layer = layui.layer;
        form.on('submit(submit)', function (data) {
            $.post("{:url('add')}", data.field, function (res) {
                if (res.code > 0) {
                    layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                        location.href = res.url;
                    });
                } else {
                    layer.msg(res.msg, {time: 1800, icon: 2});
                }
            });
        })
    });
</script>